import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Demo2 {
    public static volatile   int flag =0;
    public static void main(String[] args) {
        Thread t1 =new Thread(()->{

            while (flag==0){

            }
            System.out.println("t1线程结束");
        });
        Thread t2 =new Thread(()->{
            Scanner scanner =new Scanner(System.in);
            System.out.println("flag修改值为 ：");
            flag =scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
